package com.jxinternet.platform.services.util;

/**
* JAVA 返回随机数，并根据概率、比率
* @author zhanglei
*
*/
public class LotteryUtil
{


    /**
     *
     * @param rate0
     * @return
     */
    public static boolean PercentageRandom(Double rate0)
    {
        double randomNumber;
        randomNumber = Math.random();
        if (randomNumber >= 0 && randomNumber <= rate0)
        {
            return true;
        }

        return false;
    }

    /**
     * 测试主程序
     * @param agrs
     */
    public static void main(String[] agrs)
    {
        int i = 0;
        LotteryUtil a = new LotteryUtil();
        for (i = 0; i <= 100; i++)//打印100个测试概率的准确性
        {
            System.out.println(LotteryUtil.PercentageRandom(0.0353d));
        }
    }
}
